﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Collections;

/// <summary>
/// Summary description for CalenderRepository
/// </summary>
public  static class CalenderRepository
{
	 
   
        #region Global Properties

      
    

        #endregion

            
       
        
        public static bool AddEvent(CalendarEvent cEvent)
        {
            DataCalendarDataContext DCD = new DataCalendarDataContext();
            try
            {
                
                DCD.CalendarEvents.InsertOnSubmit(cEvent);
                DCD.SubmitChanges();
                //long JobID = cEvent.id;

                return true;
               
            }
            catch
            {
                return false;
            }
        }
        public static List<GetDoctorsByCalendarEventDoctorIdResult> GetDoctorsByCalenderDrID()
        {
            DataCalendarDataContext DCD = new DataCalendarDataContext();
            try
            {

                return (from p in DCD.GetDoctorsByCalendarEventDoctorId()
                       
                        select p).ToList();

            }
            catch
            {
                return null;
            }

        }

        public static List<GetDoctorsBYCalendarEventDrIDResult> GetDoctorsByCalenderEventDrID(int? id)
        {
            DataCalendarDataContext DCD = new DataCalendarDataContext();
            try
            {

                return (from p in DCD.GetDoctorsBYCalendarEventDrID(id)

                        select p).ToList();

            }
            catch
            {
                return null;
            }

        }
        public static List<GetDentistBYDentistCalendarDrIdResult> GetDentistByDentistCalendarDentistID(int? id)
        {
            DataCalendarDataContext DCD = new DataCalendarDataContext();
            try
            {

                return (from p in DCD.GetDentistBYDentistCalendarDrId(id)

                        select p).ToList();

            }
            catch
            {
                return null;
            }

        }
       
        public static List<GetStandByDoctorsResult> GetStandByDoctors( string state,int? spec)
        {
            DataCalendarDataContext DCD = new DataCalendarDataContext();
            try
            {

                return (from p in DCD.GetStandByDoctors(state, spec)

                        select p).ToList();

            }
            catch
            {
                return null;
            }

        }
        public static GetDoctorsApointmentDetialsResult GetDoctorsApointmentDetials(int? id)
        {
            DataCalendarDataContext DCD = new DataCalendarDataContext();
            try
            {

                return (from p in DCD.GetDoctorsApointmentDetials(id)

                        select p).Single();

            }
            catch
            {
                return null;
            }

        }
        public static GetDentistAppointmentDetailsResult GetDentistAppointmentDetials(int? id)
        {
            DataCalendarDataContext DCD = new DataCalendarDataContext();
            try
            {

                return (from p in DCD.GetDentistAppointmentDetails(id)

                        select p).Single();

            }
            catch
            {
                return null;
            }

        }

        public static List<CalendarEvent> GetCalendarEventsBYDrId(int? id)
        {
            DataCalendarDataContext DCD = new DataCalendarDataContext();
            try
            {

                return (from p in DCD.CalendarEvents

                        where p.doctorID==id
                        select p).ToList();

            }
            catch
            {
                return null;
            }

        }
        public static List<DentistCalendar> GetDentistEventsBYDentistId(int? id)
        {
            DataCalendarDataContext DCD = new DataCalendarDataContext();
            try
            {

                return (from p in DCD.DentistCalendars

                        where p.dentistId == id
                        select p).ToList();

            }
            catch
            {
                return null;
            }

        }
        public static List<tbl_Speciality> GetSpeciality()
        {
            DataCalendarDataContext DCD = new DataCalendarDataContext();
            try
            {

                return (from p in DCD.tbl_Specialities


                        select p).ToList();

            }
            catch
            {
                return null;
            }

        }
        public static tbl_Doctor GetDoctorById(int? id)
        {
            DataCalendarDataContext DCD = new DataCalendarDataContext();
            try
            {

                return (from p in DCD.tbl_Doctors
                       
                        where p.Id == id
                        
                        select p).Single();
                


            }
            catch
            {
                return null;
            }

        }
        public static bool AddDoctorSpecialty(tbl_Speciality speciality)
        {
            DataCalendarDataContext DCD = new DataCalendarDataContext();
            try
            {
                DCD.tbl_Specialities.InsertOnSubmit(speciality);
                DCD.SubmitChanges();
                return true;

            }
            catch
            {
                return false;
            }
        }
        public static bool AddDentistSpecialty(tbl_DentistSpecialty cEvent)
        {
            DataCalendarDataContext DCD = new DataCalendarDataContext();
            try
            {
                DCD.tbl_DentistSpecialties.InsertOnSubmit(cEvent);
                DCD.SubmitChanges();
                return true;

            }
            catch
            {
                return false;
            }
        }
    
}
